import { createCommentVNode, createVNode } from 'vue'
import * as $Icon from '@ant-design/icons-vue'

export const AsideMenuIcon = (props: { icon?: string | null }) => {
    let { icon } = props
    // @ts-ignore
    if (icon && icon !== null && icon !== 'null') {
        if (!icon.startsWith('data:') && icon.indexOf('-') > -1) {
            icon = icon.split('-').map(item => {
                return item.slice(0, 1).toUpperCase() + item.slice(1)
            })
            icon = icon.join('')
        }
        // @ts-ignore
        return $Icon[icon] && $Icon[icon] !== null ? createVNode($Icon[icon]) : createVNode('img', { src: icon })
    } else {
        return createCommentVNode(' empty icon')
    }
}
